<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>员工管理</title>
    <#include "/common/link.ftl">
</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="employee"/>
    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>修改密码</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-horizontal" action="#" method="post" id="editForm" >
                    <div class="form-group" style="margin-top: 10px;">
                        <label class="col-sm-2 control-label">原密码：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="password_old" placeholder="请输入原密码">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label class="col-sm-2 control-label">新密码：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="password_new" placeholder="请输入新密码">
                        </div>
                    </div>
                    <div class="col-sm-offset-1 col-sm-6">
                        <button type="button" class="btn btn-primary btn-submit">确认修改</button>
                    </div>

                </form>
                <script>
                    $(function () {
                        $(".btn-submit").click(function () {
                            $.post("/savePassword",$("#editForm").serialize(),function (data) {
                                if (data.success){
                                    //修改成功
                                    Swal.fire({
                                        title: data.msg,
                                        icon: 'success'
                                    }).then(() => {
                                        window.location.href="/login.html"
                                    })
                                }else{
                                    //原密码错误
                                    Swal.fire({
                                        title: data.msg,
                                        icon: 'warning'
                                    }).then(() => {
                                        window.location.reload();
                                    })
                                }
                            })
                        })
                    })
                </script>

            </div>
        </section>
    </div>
    <#include "/common/footer.ftl">
</div>
</body>
</html>
